import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image } from '@tarojs/components'
import { AtButton } from 'taro-ui'
import { DNavBar } from '@/components'
import './index.scss'
import sdk from '@/common/sdk'

export default class RegisterSuccess extends Component {
    state = {
        successIcon: require('../../assets/images/success@2x.png')
    }

    toLogin() {
        var u = navigator.userAgent;
        var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
        var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端

        if (isAndroid) {
            if (window.bridge) {
                return window.bridge.callHandler('logout', {}, function responseCallback(res) { })
            }
        }

        if (isiOS) {
            window.webkit.messageHandler.backToHomepage()
            return
        }
    }

    render() {
        const { successIcon } = this.state

        return (
            <View className="b_register_success">
                <DNavBar title="注册成功"></DNavBar>

                <View className="container">
                    <View className="top_icon">
                        <Image src={successIcon} className="img"></Image>
                        <Text className="text">恭喜您注册成功</Text>
                    </View>

                    <View className="info">
                        <View className="info_title">
                            <View className="top">接下来会进行信息认证</View>
                            <View className="btm">完成认证后您可以体验更多业务，包括不限于</View>
                        </View>
                        <View className="info_con">
                            <View className="info_con_item">
                                <View className="top">发布寻车、车源、代购申请等</View>
                                <View className="btm">认证车商信息更靠谱</View>
                            </View>
                            <View className="info_con_item">
                                <View className="top">在线支付定金</View>
                                <View className="btm">车煮保证您的资金安全</View>
                            </View>
                        </View>
                    </View>

                    <View className="btns">
                        <AtButton onClick={() => {
                            Taro.navigateTo({
                                url: "/pages/myinfo/authentication"
                            })
                        }}>去认证</AtButton>
                        <Text className="look" onClick={this.toLogin.bind(this)}>去登录</Text>
                    </View>
                </View>
            </View>
        )
    }
}
